@ECHO off
IF "%~1"=="" GOTO usage
CALL mysql -u root -p"%~1" -e "create database travelDream_db; GRANT ALL PRIVILEGES ON travelDream_db.* TO travelUser@localhost IDENTIFIED BY 'travelPass'"
CALL asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --restype javax.sql.DataSource --property Port=3306:Password=travelPass:User=travelUser:ServerName=localhost:DatabaseName=traveldream_db travelDream_connection
CALL asadmin create-jdbc-resource --connectionpoolid=travelDream_connection jdbc/travelDream_connection
CALL asadmin ping-connection-pool travelDream_connection
CALL asadmin create-auth-realm --classname com.sun.enterprise.security.ee.auth.realm.jdbc.JDBCRealm --property jaas-context=jdbcRealm:datasource-jndi=jdbc/travelDream_connection:user-table=utente:user-name-column=email:password-column=password:group-table=gruppo:group-table=UtenteGruppo:group-table-user-name-column=email:group-name-column=nomeGruppo:digestrealm-password-enc-algorithm=MD5 travelDreamRealm
PAUSE
END

:usage
ECHO Usage: test.bat "yourRootPasswordMySQL"
PAUSE
END